Skip to content

Conversation

@paul-fresquet
Copy link
Contributor

@paul-fresquet paul-fresquet commented Nov 9, 2025

Context

Inventory can hit access errors (e.g. UnauthorizedAccessException, protected system folders, POSIX permissions). Previously this could stop the inventory and/or allow rules to propose actions to/from locations that were not actually accessible.

What this PR does

  • Keep scanning on access errors and log warnings.
  • Explicitly mark items that are present but not accessible via IsAccessible (on all FileSystemDescription types).
  • Block any synchronization action to/from an inaccessible location (validators/rules guardrails).
  • Improve comparison UI: warning icon + tooltip for items with access issues.
  • Add unit and integration tests (Windows ACL / Linux & macOS chmod) with permission restore and cleanup.

Technical details (summary)

  • Model
    • Add bool IsAccessible { get; set; } = true; on FileSystemDescription.
  • Identification (InventoryBuilder)
    • Replace Get*() with Enumerate*() + try/catch on UnauthorizedAccessException, DirectoryNotFoundException, IOException.
    • Inaccessible directories/files: recorded as present with IsAccessible=false, not registered for analysis; identified volume not increased.
  • Comparison & Rules
    • ExistsOn considers presence even if inaccessible (prevents false "Create" proposals).
    • AtomicActionConsistencyChecker rejects when source or any target has a FileDescription with IsAccessible=false.
    • Localization: new messages for access-related validation failures.
  • UI
    • ContentIdentity: new computed property HasAccessIssue.
    • ContentIdentityViewModel/View: warning icon + access-specific tooltip.

Tests

  • Unit (green)
    • Presence of an inaccessible file → ExistsOn returns true (presence) while analysis is excluded.
    • Validators: reject sync when source is inaccessible.
    • UI: warning icon and tooltip on access issues.
  • Integration (OS-specific)
    • Windows: apply read Deny ACL on the target file; validator rejects with one of the expected reasons (inaccessible or analysis error depending on timing). ACL restored in finally.
    • Linux/macOS: chmod 000 on the target file; same validation; permissions restored (0644) in finally.
    • Test directories are always deleted after tests.

User impact

  • Robust inventories (no stop on protected paths).
  • Inaccessible items are visible and clearly flagged.
  • No sync actions are ever proposed to/from an inaccessible location.

Compatibility

  • Backward compatible: existing inventories (without IsAccessible) default to accessible.

Notes

  • Depending on platform/timing, a protected target may surface as either "not accessible" or "analysis error"; in all cases, sync is blocked.
  • Logging: warnings (not errors) for access issues.

Checklist

  • Model, scanning, comparison, validators
  • UI/UX (icon + tooltip)
  • FR/EN localizations for new messages
  • Unit + integration tests
  • Permissions restored and directories cleaned up at the end of tests

@paul-fresquet paul-fresquet changed the title feature/inventory inaccessible handling [feature] Inventory inaccessible handling Nov 10, 2025
Copilot finished reviewing on behalf of paul-fresquet November 15, 2025 13:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements comprehensive handling for inaccessible files and directories during inventory scanning. When the application encounters permission issues (UnauthorizedAccessException, DirectoryNotFoundException, IOException), it now continues scanning while marking affected items as inaccessible rather than stopping the entire inventory process.

Key changes:

  • Added IsAccessible property to FileSystemDescription model to track accessibility status
  • Implemented robust error handling in InventoryBuilder with try/catch blocks around file system operations
  • Created condition matcher abstraction to support synchronization rules
  • Added UI indicators (warning icons and tooltips) for inaccessible items
  • Implemented validators to block synchronization actions on inaccessible files
  • Added comprehensive unit and integration tests with OS-specific permission handling

Reviewed Changes

Copilot reviewed 51 out of 52 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
FileSystemDescription.cs Added IsAccessible boolean property with default value of true
InventoryBuilder.cs Refactored to use EnumerateFiles/Directories, added try/catch blocks for access exceptions, mark inaccessible items
FileSystemInspector.cs New abstraction for file system checks (hidden, system, reparse point, etc.)
ContentIdentity.cs Added access issue tracking with AccessIssueInventoryParts collection and HasAccessIssue computed property
AtomicActionConsistencyChecker.cs Added validation to block sync actions when source/target is inaccessible
ContentIdentityViewModel.cs Added HasAccessIssue property and UI logic to show warning icons for inaccessible items
ComparisonItemViewModel.cs Changed collections from HashSet to List for sorting, added sorting by inventory part codes
InventoryComparer.cs Added PropagateAccessIssuesFromAncestors to mark items under inaccessible directories
SynchronizationRuleMatcher.cs Refactored to use condition matcher factory pattern
ConditionMatchers/* New matcher classes for content, size, date, presence, and name conditions
ContentIdentityExtractor.cs Extracted content identity retrieval logic from matcher
Resources files Added localization strings for access-related errors and UI messages
Test files Comprehensive unit and integration tests with Windows ACL and POSIX permission handling
docs/testing-permissions-and-symlinks.md Detailed documentation for testing permission scenarios
CI pipeline Modified to handle integration tests differently on macOS (no coverage, added diagnostics)
Files not reviewed (1)
  • src/ByteSync.Client/Assets/Resources/Resources.Designer.cs: Language not supported
Comments suppressed due to low confidence (1)

src/ByteSync.Client/ViewModels/Sessions/Comparisons/Results/ContentIdentityViewModel.cs:207

  • Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Continue inventory scanning and track inaccessible directories instead of failing

2 participants